<?php
sfContext::getInstance()->getConfiguration()->loadHelpers('Url');
sfContext::getInstance()->getConfiguration()->loadHelpers('I18N');
class CandidateForm extends sfForm{
	public function configure(){
		#sfContext::getInstance()->getConfiguration()->loadHelpers('I18N');
		$this->setWidgets(array(
				'full_name'					=> new sfWidgetFormInputText(array(), 	array('class'			=> 'not-empty',								'maxlength' => '255',		 'error-not-empty' => __('apply-error-fullname'))),
				'date_of_birth'			=> new sfWidgetFormInputText(array(), 	array('class' 		=> 'date-picker not-empty', 	'maxlength' => '10', 		 'error-not-empty' => __('apply-error-birthday'))),
				'id_card'						=> new sfWidgetFormInputText(array(), 	array('class' 		=> 'number', 				'maxlength' => '20', 		 'error-not-empty' => __('apply-error-idcard'))),	
				
				'gender'													=> new sfWidgetFormChoice(array('choices'=>ArrayData::getGender(false),'expanded'=>true)),
				'phone_number'										=> new sfWidgetFormInputText(array(), array('class' => 'number not-empty phone-number', 'maxlength' => '20', 	'error-not-empty'  => __('apply-error-phone-number'), 'error-require-phone-number' => __('apply-error-require-phone-number'))),
				'working_experience'							=> new sfWidgetFormChoice(array('choices'=> ArrayData::getWorkingExperience(),'expanded'=>false)),
				'working_position'							=> new sfWidgetFormInputText(array(), array('class' => 'autocomplete',	'data-url' => url_for2('auto-complete'),	'maxlength' => '255',	'data-action' => 'work-professional')),
				'working_experience_japanese'			=> new sfWidgetFormChoice(array('choices'=> ArrayData::getWorkingExperience(),'expanded'=>false)),
				
				'home_town'									=> new sfWidgetFormChoice(array('choices'=> ArrayData::getCities(),'expanded'=>false), array('class' => 'require-select', 'error-require-select' => __('apply-error-require-select'))),
				'current_address'						=> new sfWidgetFormChoice(array('choices'=> ArrayData::getCities(),'expanded'=>false), array('class' => 'require-select', 'error-require-select' => __('apply-error-require-select'))),
				'education'									=> new sfWidgetFormChoice(array('choices'=> ArrayData::getEducations(),'expanded'=>false)),
				
				'professional'							=> new sfWidgetFormInputText(array(), array('class' => 'autocomplete', 'data-url' => url_for2('auto-complete'), 'data-action' => 'major')),
				'language_skill'						=> new sfWidgetFormInputText(array(), array('class' => 'autocomplete', 'data-url' => url_for2('auto-complete'), 'data-action' => 'lang-skill')),
				
				'captcha'										=> new sfWidgetFormInput()
		));

		$this->setValidators(array(
				'full_name'       		=> new sfValidatorString(array('required' => true),		array('required'		=> __('candidate-error-fullname'))),
				'date_of_birth'       => new sfValidatorString(array('required' =>  true),	array('required'		=> __('candidate-error-date-of-birth'))),
				'id_card'    					=> new sfValidatorString(array('required' => false), 	array('required'		=> __('candidate-error-id-card'))),
				
				'gender'       										=> new sfValidatorChoice(array('choices'=>array_keys(ArrayData::getGender()))),
				'phone_number'     								=> new sfValidatorString(array('required' => true),		array('required'		=> __('candidate-error-phone-number'))),
				'working_experience'							=> new sfValidatorChoice(array('choices'=>array_keys(ArrayData::getWorkingExperience()))),
				'working_position'						=> new sfValidatorString(array('required' => false)),
				'working_experience_japanese'			=> new sfValidatorChoice(array('choices'=>array_keys(ArrayData::getWorkingExperience()))),
				
				'home_town'											=> new sfValidatorChoice(array('choices'=>array_keys(ArrayData::getCities()))),
				'current_address'								=> new sfValidatorChoice(array('choices'=>array_keys(ArrayData::getCities()))),
				'education'											=> new sfValidatorChoice(array('choices'=>array_keys(ArrayData::getEducations()))),
				
				'professional'										=> new sfValidatorString(array('required' => false)),
				'language_skill'									=> new sfValidatorString(array('required' => false)),
				
				'captcha'													=> new sfValidatorString(array('required' => false)),
		));
		parent::configure();
		/*
		 * Setting name of form
		*/
		$this->setDefault('gender', USER_DEFINED::GENDER_MALE);
		$this->setDefault('education', USER_DEFINED::EDUCATION_JUNIOR_HIGH_SCHOOL);
		
		$this->widgetSchema->setNameFormat('Candidate[%s]');
		$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
	}
}

